/*
* $Id: InspectManager.h 154 2010-09-27 08:10:48Z volok-aleksej@yandex.ru $
*
* Copyright 2010 by Volokitin Alexey
* All rights reserved
*
*/
#ifndef _INSPECT_MANAGER_H_
#define _INSPECT_MANAGER_H_

#include "Components/Journal/JournalInterface.h"

class CInspectManager
{
public:
	struct journal{
		int m_nIdFamily;
		time_t m_date;
		int m_nFrame;
		int m_nStrength;
		Journal::queen_bee m_nQBState;
		int m_nWax;
		int m_nAmbrosia;
		int m_nEvacuation;
		int m_nDieting;
		Journal::disease m_nDisease;
		std::tstring m_strNote;
		int m_nIdRecord;
		journal();
		journal(const journal& jrn);
		void operator = (const journal& jrn);
	};
	struct inspect{
		std::tstring m_strNameHousing;
		int m_nIdHousing;
		int m_nHoney;
		int m_nBrood;
		int m_nGoodHoney;
		int m_nOpenBrood;
		int m_nCloseBrood;
		inspect();
		inspect(const inspect& ins);
		void operator = (const inspect& ins);
	};
	struct lastInspect{
		int m_nIdJournal;
		int m_nFrame;
		int m_nStrength;
		int m_nHoney;
		int m_nBrood;
		int m_nHousing;
		int m_nWax;
		int m_nQBState;
		lastInspect();
		lastInspect(const lastInspect& ins);
		void operator = (const lastInspect& ins);
	};
private:
	std::map<int, journal> m_aJournal;
	std::map<int, std::vector<inspect> > m_aInspects;
	std::map<int, std::vector<int> > m_aFmlJrnl;
	std::map<int, int> m_aFmlLastJrnl;
private:
	void DelInspect(int nId, IDatabase* pDb);
public:
	CInspectManager();
	~CInspectManager();
public:
	void Init();
	std::map<int, journal> GetFamilyJournal(int nIdFamily);
	lastInspect GetFamilyLastJournal(int nIdFamily);
	journal GetJournal(int nIdJournal);
	std::vector<inspect> GetInspects(int nIdJournal);
	void AddInspect(journal jrn, const std::vector<inspect>& aInspects, const std::map<std::tstring, std::tstring>& aUserFields);
	void ChangeInspect(int nId, journal jrn, const std::vector<inspect>& aInspects, const std::map<std::tstring, std::tstring>& aUserFields);
	void DeleteInspect(int nId);
	void DeleteInspects(int nIdFamily);
};

#endif/*_INSPECT_MANAGER_H_*/
